<template>
	<!-- 刘振坤 2023年4月37号 -->
	<!-- 用户全部评论 -->
	<view style="width:96%;margin-left: 2%;">
		<u-navbar
			height="44px"
			title="评论列表"
			:autoBack="true"
		></u-navbar>
		<view style="width:100%;margin-top: 50px;">
			<view style="width:100%;height:30px;line-height:30px;">
				<span>商品评价( {{ this.total }} )</span>
				<!-- {{ calculateTheTotalNumberOfCommentsList.totalQuantity }} -->
			</view>
			<view v-for="(item, index) in calculateTheTotalNumberOfCommentsList" :key="index">
				<view style="width: 97%;height: 40px;margin-top: 10px;line-height: 40px;">
					<img style="width: 12%;height: 40px;float:left;" :src="item.url">
					<view style="float:left;;height: 40px;">
						<view style="font-size:18px;color:grey;margin-left:10px;height:20px;margin-top: -10px;">{{ item.name }}</view>
						<view style="font-size: 12px;height:20px;margin-left:10px;">{{ item.createTime }}</view>
					</view>
					<u-rate style="float:right;position:relative;top:12px;" count="5" v-model="value" size="18px"></u-rate>
				</view>
				<view style="word-break:break-all;font-size:14px;width:97%;margin-top:10px;overflow:hidden;">
					{{ item.content }}
				</view>
				<view style=";width:97%;margin-top:10px;word-break:break-all;">
					<img v-for="img in item.commentImgList":src="img" style="width:23.4%;height:80px;margin-right:5px;">
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				// 评分默认选中几个
				value: '',
				// 获取限时抢购页面点击评论按钮传来的id参数 商品id
				cid: '',
				// 获取限时抢购页面点击评论按钮传来的id参数 评论总数量
				total: '',
				// 查询所有评论
				calculateTheTotalNumberOfCommentsList: [],
			}
		},
		onLoad(option) {
			// 获取限时抢购页面点击评论按钮传来的id参数
			this.cid = option.pid
			this.total = option.total
			this.queryAllComments()
		},
		methods: {
			// 查询所有评论
			queryAllComments(){
				this.$myRequest({
					url: '/limitedTimePurchase/queryAllComments',
					data: {
						cid: this.cid
					}
				}).then(res=>{
					if(res.data.flag){
						this.calculateTheTotalNumberOfCommentsList = res.data.data
						for (var i = 0; i < this.calculateTheTotalNumberOfCommentsList.length; i++) {
							this.calculateTheTotalNumberOfCommentsList[i].commentImgList =[]
							var imgIds = this.calculateTheTotalNumberOfCommentsList[i].pictureGroup.split(',')
							for (var j = 0; j < imgIds.length; j++) {
								this.calculateTheTotalNumberOfCommentsList[i].commentImgList.push('http://101.43.223.224:8765/image/getImageById?id='+imgIds[j])
							}
						}
					}else{
						this.calculateTheTotalNumberOfCommentsList = []
					}
				})
			},
		}
	}
</script>

<style>

</style>
